package com.gange.controller;

import com.gange.pojo.Dept;
import com.gange.pojo.Result;
import com.gange.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Slf4j
@RestController
@RequestMapping("/depts")
public class DeptController {
    @Autowired
    private DeptService ds;
    @GetMapping
    public Result list(){
        List<Dept> all = ds.findAll();
        return Result.success(all);
    }
    @PostMapping
    public Result add(@RequestBody Dept dept){
        System.out.println(ds.getClass());
        ds.add(dept);
        return Result.success();
    }
}
